package birdsong.comm;

import java.io.Serializable;

import birdsong.comm.ServerSideMessage;


/**
 * This class represents the messages received by the server.
 * 
 * @author Bruno Parra, Leo Dias, Miguel Lemos, Ruben Gomes
 * @version 1.0
 */
public class BirdSongServerSideMessage implements Serializable, ServerSideMessage {

	private Type type;
	private String payLoad;
	private String nickName;

	/**
	 * Construct's a {@link BirdSongServerSideMessage}.
	 * 
	 * @param type, the message type {@link ServerSideMessage.Type}.
	 * @param payLoad, the message body.
	 * @param nickName, the nickname of the sender.
	 */
	public BirdSongServerSideMessage(final Type type, final String payLoad, final String nickName){
		assert type != null;
		assert nickName != null && !nickName.isEmpty();
		this.type = type;
		this.payLoad = payLoad;
		this.nickName = nickName;
	}

	/**
	 * @return the type of the message {@link ServerSideMessage.Type}.
	 */	
	public Type getType() {
		return type;
	}

	/**
	 * @return the message content.
	 */
	public String getPayload() {
		return payLoad;
	}

	/**
	 * @return the client's nickname.
	 */
	public String getClientNickname() {
		return nickName;
	}
}